/*     */ package com.qmsk.business.manage.user.controller;
/*     */ 
/*     */ import com.qmsk.business.manage.user.dao.RegisterDAO;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/hostReg"})
/*     */ public class RegisterController
/*     */ {
/*  34 */   private static final Logger logger = Logger.getLogger(RegisterController.class);
/*     */ 
/*     */   @Autowired
/*     */   private RegisterDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/all/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  53 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  55 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/*  56 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  58 */       logger.error(e);
/*  59 */       ResponseUtils.setErrorMsgResponse(
/*  60 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  76 */     String sGsonInData = RequestUtils.getString(request, "data");
/*     */     try {
/*  78 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/*  79 */       DbConnection.commit();
/*  80 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  81 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  82 */         response);
/*     */     } catch (Exception e) {
/*  84 */       DbConnection.rollback();
/*  85 */       logger.error(e);
/*  86 */       ResponseUtils.setErrorMsgResponse(
/*  87 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/*  88 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insertList(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 107 */       int nResult = 0;
/* 108 */       String sData = RequestUtils.getStringOfData(request);
/* 109 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 110 */       if (p != null) {
/* 111 */         if ((p.getListInsertRows() != null) && 
/* 112 */           (p.getListInsertRows().size() > 0)) {
/* 113 */           for (int i = 0; i < p.getListInsertRows().size(); ++i) {
/* 114 */             GsonHeadOneRow r = (GsonHeadOneRow)p.getListInsertRows().get(i);
/* 115 */             r.autoAddHeadData("tmAdd", new Date());
/*     */           }
/*     */         }
/* 118 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 120 */       if (nResult > 0)
/* 121 */         DbConnection.commit();
/*     */       else {
/* 123 */         DbConnection.rollback();
/*     */       }
/* 125 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 126 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 127 */         response);
/*     */     } catch (Exception e) {
/* 129 */       DbConnection.rollback();
/* 130 */       logger.error(e);
/* 131 */       ResponseUtils.setErrorMsgResponse(
/* 132 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 133 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 149 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 151 */       String[] strParams = id.split(",");
/* 152 */       int nResult = this.dao.deleteParams(strParams);
/* 153 */       DbConnection.commit();
/* 154 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 155 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 156 */         response);
/*     */     } catch (Exception e) {
/* 158 */       DbConnection.rollback();
/* 159 */       logger.error(e);
/* 160 */       ResponseUtils.setErrorMsgResponse(
/* 161 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 162 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 178 */     String id = request.getParameter("id");
/* 179 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 181 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 182 */       if (g == null) {
/* 183 */         ResponseUtils.setErrorMsgResponse(
/* 184 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 185 */           response);
/* 186 */         return; }
/* 187 */       int nResult = this.dao.updateJsonOneRow(g, id);
/* 188 */       DbConnection.commit();
/* 189 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 190 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 191 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 194 */       DbConnection.rollback();
/* 195 */       logger.error(e);
/* 196 */       ResponseUtils.setErrorMsgResponse(
/* 197 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 198 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"check"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void check(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 214 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 216 */       String[] strParams = id.split(",");
/* 217 */       int nResult = this.dao.check(strParams);
/* 218 */       DbConnection.commit();
/* 219 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 220 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 221 */         response);
/*     */     } catch (Exception e) {
/* 223 */       DbConnection.rollback();
/* 224 */       logger.error(e);
/* 225 */       ResponseUtils.setErrorMsgResponse(
/* 226 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 227 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.manage.user.controller.RegisterController
 * JD-Core Version:    0.5.3
 */